﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FTBS.Models;
using FTBS.Models.DAO;
using FTBS.Models.Entities;

namespace FTBS.Models.BLO
{
    public class FormatBLO
    {
        private FormatDAO _formatDao = new FormatDAO();

        /// <summary>
        /// get list of formats
        /// </summary>
        /// <returns>List of formats</returns>
        /// <author>hungph</author>
        public List<Format> LoadFormats()
        {
            var listFormat = _formatDao.LoadFormats();
            return listFormat;
        }

        /// <summary>
        /// get a format by formatID
        /// </summary>
        /// <returns>Format</returns>
        /// <author>hungph</author>
        public Format LoadFormatsById(int id)
        {
            var format = _formatDao.LoadFormatsById(id);
            return format;
        }

        /// <summary>
        /// Check if format name is existed or not
        /// </summary>
        /// <param name="format"></param>
        /// <returns>bool</returns>
        /// <author>hungph</author>
        /// <date>3/3/2014</date>
        public bool CheckIsExisted(Format format)
        {
            return (_formatDao.CheckIsExisted(format));
        }

        /// <summary>
        /// create a new format of film
        /// </summary>
        /// <returns>bool</returns>
        /// <author>hungph</author>
        public bool CreateFormat(Format format)
        {
            var result = _formatDao.Add(format);
            if (result == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// edit info format of film
        /// </summary>
        /// <returns>bool</returns>
        /// <author>hungph</author>
        public bool EditFormat(Format format)
        {
            var result = _formatDao.Edit(format);
            if (result == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// delete format
        /// </summary>
        /// <returns>bool</returns>
        /// <author>hungph</author>
        public bool DeleteFormat(Format format)
        {
            var result = _formatDao.Delete(format);
            if (result == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public Format GetFormatById(int id)
        {
            var format = _formatDao.GetFormatById(id);
            return format;
        }
    }
}